/*******************************************************************************
 * Copyright (c) 2008 L.Carbonnaux.
 *******************************************************************************/
package org.lcx.taskvision.core;

import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel;

/**
 * @author Laurent Carbonnaux
 */
public interface ITaskVisionConstants {

	public static final String PREF_REPOSITORY_UPLOADED_URL = 		"com.lcx.scrumvision.values.repository.uploaded.url";

	
	public static final String PREF_SPREADSHEET_ID = 		"com.lcx.scrumvision.values.spreadsheet.id";
	public static final String PREF_SPREADSHEET_NAME = 		"com.lcx.scrumvision.values.spreadsheet.name";
	public static final String PREF_FOLDER_ID 		= 		"com.lcx.scrumvision.values.floder.id";
	public static final String PREF_FOLDER_NAME 	= 		"com.lcx.scrumvision.values.floder.name";
	
	public static final String PREF_WORKSHEET_ID = 			"com.lcx.scrumvision.values.worksheet.url";
	public static final String PREF_WORKSHEET_NAME = 		"com.lcx.scrumvision.values.worksheet.name";
	public static final String PREF_WORKSHEET_WSURL = 		"com.lcx.scrumvision.values.worksheet.wsurl";
	public static final String PREF_WORKSHEET_CFURL = 		"com.lcx.scrumvision.values.worksheet.cfurl";

	public static final String PREF_TAG_NAME 		= 		"com.lcx.scrumvision.values.tag.name";

//	public static final String PREF_LEVEL_TAGS_COUNT = 		"com.lcx.scrumvision.count.level.tags";
	
	public static final char   PREF_DELIM_REPOSITORY = 	':';
	public static final char   PREF_DELIM_SPREADSHEET = '!';
	public static final char   PREF_DELIM_WORKSHEET = 	'#';
	
	public static final String PREF_UPDATE_ALL_TASK		 = "com.lcx.scrumvision.ui.pref.updatealltask";
	public static final String PREF_USE_FIBONACCI		 = "com.lcx.scrumvision.ui.pref.usefibonacci";

	public static final String REP_TYPE_KEY = 			"com.lcx.scrumvision.rep.key";
	public static final String REP_TYPE_GLOBAL = 		"Global";
	public static final String REP_TYPE_SPREADSHEET = 	"Spread Sheet";
	public static final String REP_TYPE_WORKSHEET = 	"Work Sheet";
	
	public static final String PARAMETER_DATES = 		"Dates";
	public static final String PARAMETER_DAYS = 		"Days";
	
	public static final String WORKSHEET_SPRINTS = 		"Sprints";
	public static final String WORKSHEET_FEATURES = 	"Features";
	public static final String WORKSHEET_USERSTORIES = 	"USerStories";
	public static final String WORKSHEET_SPRINT_TPL =	"Sprint_TPL";
	public static final String WORKSHEET_SPRINT_PREF =	"Sprint_";
	
	
	
	public static final int NBDAYS	=					20;
	
	public static enum TASK_OPERATION {
		none, changestatus, reassign;
	}

	// TODO : should be managed by the spreadsheet itself
	public static enum TASK_STATUS {
		NOT_STARTED("Not Started"),
		IN_PROGRESS("In Progress"),
		COMPLETED("Completed"),
		BLOCKED("Blocked"),
		CANCELLED("Cancelled");

		private final String value;
		
		private TASK_STATUS(String value){
			this.value = value;
		}
		@Override
		public String toString() {
			return value;
		}
		
		public static TASK_STATUS getDefault(){
			return NOT_STARTED;
		}

		public static String[] getList(){
			String[] tab = new String[TASK_STATUS.values().length];
			int i = 0;
			for (TASK_STATUS status : TASK_STATUS.values()) {
				tab[i] = status.toString();
				i++;
			}
			return tab;
		}
	}
	
	/**
	 * This is MoSCoW
	 */
	 // TODO : should be managed by the spreadsheet itself
	public static enum TASK_PRIORITY {
		M("Must", "P1"), S("Should", "P2"), C("Could", "P4"), W("Would", "P5");

		private final String label;
		private final String priority;
		
		private TASK_PRIORITY(String label, String priority){
			this.label = label;
			this.priority = priority;
		}

		public String getLabel() {
			return label;
		}

		public String getPriority() {
			return priority;
		}
		
		public static TASK_PRIORITY getDefault(){
			return M;
		}
		
//		@Override
//		public String toString() {
//			return label;
//		}

		public static String[] getList(){
			String[] tab = new String[TASK_PRIORITY.values().length];
			int i = 0;
			for (TASK_PRIORITY task : TASK_PRIORITY.values()) {
				tab[i] = task.getLabel();
				i++;
			}
			return tab;
		}
		
		public static String getPriorityFromFeed(String priority) {
			String value = PriorityLevel.getDefault().toString();
			if(priority!=null) {
				for (TASK_PRIORITY prio : TASK_PRIORITY.values()) {
					if(prio.getLabel().equals(priority)) value = prio.getPriority();
				}
			}
			return value;
		}

		public static String getPriorityFromValue(String priority) {
			String value = PriorityLevel.getDefault().toString();
			if(priority!=null) {
				for (TASK_PRIORITY prio : TASK_PRIORITY.values()) {
					if(prio.getLabel().equals(priority)) value = prio.toString();
				}
			}
			return value;
		}

		public static String getLabelFromValue(String priority) {
			String value = PriorityLevel.getDefault().toString();
			if(priority!=null) {
				for (TASK_PRIORITY prio : TASK_PRIORITY.values()) {
					if(prio.toString().equals(priority)) value = prio.getLabel();
				}
			}
			return value;
		}
	}

	/**
	 * Task and query type
	 */
	 //
	public static enum TASK_TYPE {
		TASK("Task", "task"),
		SPRINT("Sprint", "sprt"), 
		FEATURE("Feature", "feat"), 
		USERSTORY("User story", "usto"); 

		private final String label;
		private final String prefix;
		public static final int PREFIX_LENGTH = 4;
		
		private TASK_TYPE(String label, String prefix){
			this.label = label;
			this.prefix = prefix.substring(0, PREFIX_LENGTH);
		}

		public String getLabel() {
			return label;
		}

		public String getPrefix() {
			return prefix;
		}
		
		public static TASK_TYPE getDefault(){
			return TASK;
		}
		
		public static String[] getList(){
			String[] tab = new String[TASK_TYPE.values().length];
			int i = 0;
			for (TASK_TYPE task : TASK_TYPE.values()) {
				tab[i] = task.getLabel();
				i++;
			}
			return tab;
		}
		
		public static String getPrefix(String label) {
			String value = TASK_TYPE.getDefault().getLabel();
			if(label!=null) {
				for (TASK_TYPE type : TASK_TYPE.values()) {
					if(type.getLabel().equals(label)) value = type.getPrefix();
				}
			}
			return value;
		}

		public static String getLabel(String prefix) {
			String value = TASK_TYPE.getDefault().getLabel();
			if(prefix!=null) {
				for (TASK_TYPE type : TASK_TYPE.values()) {
					if(type.getPrefix().equals(prefix)) value = type.getLabel();
				}
			}
			return value;
		}
	}
	
}
